// 时间
export const dateFormat = (time) => {
  var date = new Date(time);
  var year = date.getFullYear();
  var month =
    date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1;
  var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  var minutes =
    date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  var seconds =
    date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  // 拼接
  return (
    year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
  );
};

export const getHtmlTime = date => {
  let data = new Date(date);
  let Y = data.getFullYear();
  let M = data.getMonth() + 1;
  let D = data.getDate();
  let H = data.getHours();
  let Min = data.getMinutes();
  let S = data.getSeconds();
  let W = data.getDay();
  H = H < 10 ? "0" + H : H;
  Min = Min < 10 ? "0" + Min : Min;
  S = S < 10 ? "0" + S : S;
  switch (W) {
    case 0:
      W = "日";
      break;
    case 1:
      W = "一";
      break;
    case 2:
      W = "二";
      break;
    case 3:
      W = "三";
      break;
    case 4:
      W = "四";
      break;
    case 5:
      W = "五";
      break;
    case 6:
      W = "六";
      break;
    default:
      break;
  }

  const html =
    "<span >" +
    " 日期: " +
    "</span>" +
    Y +
    "<span >" +
    " 年 " +
    "</span>" +
    M +
    "<span >" +
    " 月 " +
    "</span>" +
    D +
    "<span>" +
    " 日  " +
    "</span>" +
    "<span >" +
    " 星期" +
    W +
    "  " +
    "</span>" +
    "<span >" +
    H +
    ":" +
    Min +
    ":" +
    S;
  ("</span>");

  return html;

}
